<template>
	<view class="content">
		<view class="scroll-view_H">
			<view v-for="(item, index) in collectList" :key="index"  >
				<view class="con" >
					<view class="img" @click="goPath(item.dataId)"><image :src="item.extJSON.previewUrl" mode=""></image></view>
					<view class="name">
						<view class="" @click="goPath(item.dataId)">
							<view class="one" >
								<view class="left">{{ item.extJSON.goodsName }}</view>
							</view>
							
							<view class="three">{{item.extJSON.businessName}}</view>
						</view>
						<view class="four" style="">
							<view class="">
								￥{{ item.extJSON.goodsPrice }}
							</view>
							<view class="" @click="delcollect(item.id)">
								<uv-icon name="heart-fill" size="26" color="#ff2a66"></uv-icon>
							</view>
						</view>
						<!-- <image style="width: 150rpx;height: 150rpx;" :src="goodsInfo.previewUrl" mode=""></image> -->
					</view>
				</view>
			</view>
		</view>
		
		<view class="none_list_box" v-if="collectList.length==0"  style="margin-top: 200rpx">
			<uv-empty mode="favor"></uv-empty>
		</view>
	</view>
</template>

<script>
import {
	getBusinessInfoById,
	searchPlugsGoodsByCategoryId,
	searchPlugsGoodsById,
	getRecommen,
	insertPlugsCollect,
	searchPlugsCollectByUserId,
	delPlugsCollect
} from '../../../utils/api.js';
export default {
	data() {
		return {
			collectList: [],
			tatol: 0,
			startPage: 1
		};
	},
	onReachBottom() {
		console.log(this.collectList.length, this.total);
		if (this.collectList.length < this.total) {
			this.startPage++;
			this.getcollectList();
		}
	},
	onShow() {
		this.getcollectList();
	},
	methods: {
		getcollectList() {
			uni.showLoading({
				title: '获取关注列表'
			});
			let postdata = {
				businessId: -1,
				page: 1,
				size: 50
			};
			searchPlugsCollectByUserId(postdata).then(res => {
				if (res.code == 200) {
					// this.collectList=res.body.list;

					if (this.startPage == 1) {
						this.collectList = [];
					}
					let arr = [];
					arr = this.collectList.concat(res.body.list);
					this.collectList = arr;
					this.collectList.forEach(item => {
						if (typeof item.extJSON.extJson === 'string') {
							item.extJSON.extJson = JSON.parse(item.extJSON.extJson);
						}
					});
					console.log(this.collectList, '5555');
					// this.show = false;
					uni.hideLoading();
					this.total = res.body.total;
				}
			});
		},
		goPath(id) {
			uni.navigateTo({
				url: `/pages/porduct/porduct?id=${id}`
			});
		},
		delcollect(id){
				let self = this;
				let postData = `ids=${id}`
				uni.showModal({
					title: '提示',
					content: '确定取消吗',
					success: function(res) {
						if (res.confirm) {
							delPlugsCollect( postData).then(res => {
								if (res.code == 200) {
									uni.showToast({
										title: '取消成功'
									})
									self.getcollectList();
								}
							})
						} else if (res.cancel) {
			
						}
					}
				});
		}
	}
};
</script>

<style lang="scss">
	page{
		padding: 20rpx;
		
	}
	.content{
		
	}
.scroll-view_H {
	.con {
		padding: 20rpx;
		display: flex;
		background-color: #fff;
		border-radius: 20rpx;
		.img {
			margin-right: 20rpx;
			image {
				width: 200rpx;
				height: 200rpx;
				border-radius: 20rpx;
			}
		}
		.name {
			font-size: 26rpx;
			.one {
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-weight: 700;
				font-size: 30rpx;
				.left {
				}
				.right {
				}
			}
			.two {
				color: #999;
				padding: 15rpx 0;
			}
			.three {
				color: #666;
				font-size: 22rpx;
				border-radius: 10rpx;
			}
			.four{
				width: 450rpx;
				color: #ff4544;
				padding-top: 30rpx;
				font-weight: 700;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
		}
	}
}
</style>
